import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/component/component.dart';
import 'package:leader_help/utils/util.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class GrapQuestionPage extends GetView<GrapQuestionController> {
  const GrapQuestionPage({Key? key}) : super(key: key);

  // 内容页
  Widget _buildView() {
    return ListView.separated(
        itemBuilder: (context, index) {
          var _item = controller.state.list![index];
          return GrapQuestionCell(mod: _item);
        },
        separatorBuilder: (context, index) {
          return SizedBox(
            height: 10.r,
          );
        },
        itemCount: controller.state.list?.length ?? 0);
  }

  @override
  Widget build(BuildContext context) {
    var state = controller.state;
    return GetBuilder<GrapQuestionController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(
            context,
            title: '抓问题',
            bottom: PreferredSize(
              child: Container(
                height: 50.r,
                color: ColorsUtil.bg,
                alignment: Alignment.center,
                child: Text(
                  '万人助万企，共计${state.list?.length ?? 0}项问题。请给问题目标作安排。',
                  style: pfSCStyle(color: ColorsUtil.green, fontSize: 15.sp),
                ),
              ),
              preferredSize: Size.fromHeight(50.r),
            ),
          ),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
